// caps webgl benchmark -- basically collect a bunch of capabilities
// reported by WebGL.

function caps() {
}

caps.prototype.tick = function() {
  var valnames = [
    'ALIASED_LINE_WIDTH_RANGE', // Float32Array (with 2 elements)
    'ALIASED_POINT_SIZE_RANGE', // Float32Array (with 2 elements)
    'ALPHA_BITS',
    'BLUE_BITS',
    // TODO: COMPRESSED_TEXTURE_FORMATS
    'GREEN_BITS',
    'MAX_COMBINED_TEXTURE_IMAGE_UNITS',
    'MAX_CUBE_MAP_TEXTURE_SIZE',
    'MAX_FRAGMENT_UNIFORM_VECTORS',
    'MAX_RENDERBUFFER_SIZE',
    'MAX_TEXTURE_IMAGE_UNITS',
    'MAX_TEXTURE_SIZE',
    'MAX_VARYING_VECTORS',
    'MAX_VERTEX_ATTRIBS',
    'MAX_VERTEX_TEXTURE_IMAGE_UNITS',
    'MAX_VERTEX_UNIFORM_VECTORS',
    'MAX_VIEWPORT_DIMS',
    'NUM_COMPRESSED_TEXTURE_FORMATS',
    'RED_BITS',
    'SAMPLE_BUFFERS',
    'SAMPLES',
    'STENCIL_BITS',
    'SUBPIXEL_BITS'
                  ];


  for (var i = 0; i < valnames.length; i++) {
    var valname = valnames[i];
    var value = gl.getParameter(gl[valname]);
    var valtype = typeof(value);
    if (value === null) {
      // Skip this metric.
    } else if (valtype == 'object') {
      // Deal with arrays.
      for (var j = 0; j < value.length; j++) {
        add_metric('caps/' + valname + j, value[j]);
      }
    } else {
      add_metric('caps/' + valname, value);
    }
  }
};
